package com.jstyle.jclifexd.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.demon.js_pdf.WebViewHelper;
import com.jstyle.jclifexd.R;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class BodyFatTipsActivity extends AppCompatActivity {

    @BindView(R.id.bt_device_title)
    Button btDeviceTitle;
    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.rl_title)
    RelativeLayout rlTitle;
    @BindView(R.id.webView)
    WebView webView;
    private static final String TAG = "BodyFatTipsActivity";
    public static final String KEY_BodyFatUrl = "BodyFatUrl";
    public static final String KEY_Title = "KEY_Title";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_body_fat_tips);
        ButterKnife.bind(this);
        String pdfUrl=getIntent().getStringExtra(KEY_BodyFatUrl);
        String title=getIntent().getStringExtra(KEY_Title);
        if(TextUtils.isEmpty(pdfUrl))return;
        btDeviceTitle.setText(title);
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAllowFileAccess(true);
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
        webSettings.setSupportZoom(true);//缩放开关，设置此属性，仅支持双击缩放，不支持触摸缩放
        webSettings.setBuiltInZoomControls(true);  //设置是否可缩放，会出现缩放工具（若为true则上面的设值也默认为true）

        webView.loadUrl(pdfUrl);
    }

    @OnClick(R.id.iv_back)
    public void onViewClicked() {
        finish();
    }
}
